package tinify

import (
	"net/http"
	"strconv"
)

type ResultMeta struct {
	meta http.Header
}

func NewResultMeta(meta http.Header) *ResultMeta {
	r := new(ResultMeta)
	r.meta = meta
	return r
}

func (r *ResultMeta) width() int {
	w := r.meta.Get("Image-Width")

	width, err := strconv.Atoi(w)
	if err != nil {
		return 0
	}

	return width
}

func (r *ResultMeta) height() int {
	h := r.meta.Get("Image-Height")
	height, err := strconv.Atoi(h)
	if err != nil {
		return 0
	}

	return height
}

func (r *ResultMeta) location() string {
	arr := r.meta.Get("Location")

	return arr
}